# -*- coding: utf-8 -*-
"""
Created by edc on 2020/8/10
"""
from operation.alink.utils.HDFSFS import HDFSFS
# set env
from pyalink.alink import *
import sys, os

resetEnv()
useLocalEnv(2)

HDFSServer = HDFSFS()
df_iris, schema = HDFSServer.hd2df_alink('hdfs:/data/iris.csv')
df_iris.head(5)
print(schema)
iris = BatchOperator.fromDataframe(df_iris, schema)
df_iris = iris.collectToDataframe()
df_iris.head()

# iris = BatchOperator.fromDataframe(df_iris, "sepal_length double, sepal_width double, petal_length double, petal_width double, category string")

# filePath = 'https://alink-release.oss-cn-beijing.aliyuncs.com/data-files/iris.csv'
# schema = 'sepal_length double, sepal_width double, petal_length double, petal_width double, category string'
# csvSource = CsvSourceBatchOp()\
#     .setFilePath(filePath)\
#     .setSchemaStr(schema)\
#     .setFieldDelimiter(",")
# csvSink = CsvSinkBatchOp()\
#     .setFilePath('~/csv_test.txt')
# csvSource.link(csvSink)
# BatchOperator.execute()
